package cj.web.admin.dao;
/*
 *  
 *  
*/
import java.util.List;

import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.SQL;
import net.paoding.rose.jade.annotation.SQLParam;
import cj.web.admin.domain.Permit;

/**
 * 
 * @author 
 *
 */
@DAO
public interface PermitHistoryDAO{
	
	@SQL("SELECT count(*) FROM PermitHistory WHERE deleteFlag=1 AND gameId=:1 ")
    int queryexit(int gameId);
	
	@SQL("SELECT * FROM PermitHistory WHERE deleteFlag=1 #if(:t.code!=''){ AND code LIKE '%##(:t.code)%' } ORDER BY updateAt DESC LIMIT :t.start,:t.length ")
    List<Permit> query(@SQLParam("t") Permit permit);
	
	@SQL("SELECT count(*) FROM PermitHistory WHERE deleteFlag=1 #if(:t.code!=''){ AND code LIKE '%##(:t.code)%' } ")
    int querysize(@SQLParam("t") Permit permit);
    
    @SQL("SELECT * FROM PermitHistory WHERE id=:1")
    Permit queryById(int id);
    
    @SQL("INSERT INTO PermitHistory (gameId,areaId,areaName,schoolId,schoolName,code,returnCode,pwd,pwdShow,status,deleteFlag,createAt,createUser,updateAt,updateUser) VALUES (:t.gameId,:t.areaId,:t.areaName,:t.schoolId,:t.schoolName,:t.code,:t.returnCode,:t.pwd,:t.pwdShow,:t.status,1,now(),:t.createUser,now(),:t.updateUser) ")
    void create(@SQLParam("t") Permit permit);
    
    @SQL("INSERT INTO PermitHistory (id,gameId,areaId,areaName,schoolId,schoolName,code,returnCode,pwd,pwdShow,status,deleteFlag,createAt,createUser,updateAt,updateUser) SELECT id,gameId,areaId,areaName,schoolId,schoolName,code,returnCode,pwd,pwdShow,status,deleteFlag,createAt,createUser,updateAt,updateUser FROM Permit WHERE gameId=:1 ")
    void copy(int gameId);
	
	@SQL("UPDATE PermitHistory SET gameId=:t.gameId,areaId=:t.areaId,schoolId=:t.schoolId,code=:t.code,returnCode=:t.returnCode,pwd=:t.pwd,pwdShow=:t.pwdShow,status=:t.status,updateAt=now(),updateUser=:t.updateUser WHERE id=:t.id")
    void update(@SQLParam("t") Permit permit);
    
    @SQL("UPDATE PermitHistory SET deleteFlag=0 WHERE id=:1")
    void deleteById(int id);
}